<!doctype html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:v-model="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<pre>
    变异方法

    Vue 包含一组观察数组的变异方法，所以它们也将会触发视图更新。这些方法如下：
    push()
    pop()
    shift()
    unshift()
    splice()
    sort()
    reverse()
</pre>
<div id="app">
    <ul>
        <li v-for="n of list">{{n}}</li>
    </ul>
    <button @click="push">push</button>
    <button @click="pop">pop</button>
    <button @click="shift">shift</button>
    <button @click="unshift">unshift</button>
    <button @click="splice">splice</button>
    <button @click="sort">sort</button>
    <button @click="reverse">reverse</button>
</div>
</body>
<script src="../../vender/vue@2.4.2.js"></script>
<script>

    var app=new Vue({
        el:'#app',
        data:{
            list:[0,1,2,3,4,5,6,7,8,9]
        },
        methods:{
            push: function () {
                this.list.push('10');
            },
            pop: function () {
                this.list.pop();
            },
            shift: function () {
                this.list.shift();
            },
            unshift: function () {
                this.list.unshift(-1);
            },
            splice: function () {
                this.list.splice(3,3,'a','b','c')
            },
            sort: function () {
                this.list.sort((a,b)=>a-b<0?-1:1);
            },
            reverse: function () {
                this.list.reverse();
            }
        }
    });

</script>
</html>